
package com.manager;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.manager.commons.BaseConstants;


public class BaseAction extends DispatchAction {
	
	//通过spring注入基础service
	public BaseService baseServiceImpl;
	
	/**
	 * 活动超时时间配置code
	 */
	public static final String TIME_OUT_DAY = "4100201";
	
	/**
	 * 
	 * Description: 判断提交后的转向页面
	 * @param mapping
	 * @param flag
	 * @param successMsg
	 * @param failMsg
	 * @param pageaction
	 * @param request
	 * @return ActionForward
	 * @throws Exception
	 * 
	 */
	public ActionForward pageAction(ActionMapping mapping,boolean flag,String successMsg,String failMsg,String pageaction,HttpServletRequest request)  { 
		if(flag){
		 request.setAttribute(BaseConstants.MSG, successMsg);
		 request.setAttribute(BaseConstants.PAGEACTION, pageaction);
		 return mapping.findForward(BaseConstants.SUCCESS);
		}else{
		 request.setAttribute(BaseConstants.MSG, failMsg);
		 return mapping.findForward(BaseConstants.FAILED);
		}
	}
	
	public BaseService getBaseServiceImpl() {
		return baseServiceImpl;
	}

	public void setBaseServiceImpl(BaseService baseServiceImpl) {
		this.baseServiceImpl = baseServiceImpl;
	}
    
	public String findValueByCode(String code){
		return this.baseServiceImpl.findValueByCode(code);
	}
	
}

